package com.matt.docpro.service;

import com.matt.docpro.mapper.DoctorMapper;
import com.matt.docpro.mapper.PatientMapper;
import com.matt.docpro.mapper.UserMapper;
import com.matt.docpro.model.Doctor;
import com.matt.docpro.model.Patient;
import com.matt.docpro.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.print.Doc;
import java.util.List;

/**
 * AppointmentService
 * Created by on 2024/02/20.
 */
@Service
public class DoctorService {

    @Autowired
    DoctorMapper doctorMapper;
    @Autowired
    UserMapper userMapper;

    public List<Doctor> getAll() {
        return doctorMapper.getAll();
    }

    public Doctor getById(String id) {
        return doctorMapper.getById(id);
    }

    public void update(Doctor doctor) {
        doctorMapper.update(doctor);
    }

    public int getCount() {
        return doctorMapper.getCount();
    }

    public void insert(Doctor doctor) {
        doctorMapper.insert(doctor);
        User user = new User();
        user.setId(doctor.getId());
        user.setPassword("123456");
        user.setAccount(doctor.getId());
        user.setMail(doctor.getMail());
        user.setBaned(false);
        user.setRole("1");
        userMapper.insert(user);
    }

}
